package com.ews.onlineexchange.model.approved;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.ews.onlineexchange.model.DataEntity;
import com.ews.onlineexchange.model.ServiceSupplier;

@Entity
public class AnnualReviewRecord extends DataEntity {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	private Integer				year;
	private ServiceSupplier		supplier;
	private BigDecimal			sumScore;

	@NotNull
	public Integer getYear() {
		return year;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	@ManyToOne
	@NotNull
	public ServiceSupplier getSupplier() {
		return supplier;
	}

	public void setSupplier(ServiceSupplier supplier) {
		this.supplier = supplier;
	}

	@NotNull
	@Min(0L)
	public BigDecimal getSumScore() {
		return sumScore;
	}

	public void setSumScore(BigDecimal sumScore) {
		this.sumScore = sumScore;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((sumScore == null) ? 0 : sumScore.hashCode());
		result = prime * result + ((supplier == null) ? 0 : supplier.hashCode());
		result = prime * result + ((year == null) ? 0 : year.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		AnnualReviewRecord other = (AnnualReviewRecord) obj;
		if (sumScore == null) {
			if (other.sumScore != null)
				return false;
		} else if (!sumScore.equals(other.sumScore))
			return false;
		if (supplier == null) {
			if (other.supplier != null)
				return false;
		} else if (!supplier.equals(other.supplier))
			return false;
		if (year == null) {
			if (other.year != null)
				return false;
		} else if (!year.equals(other.year))
			return false;
		return true;
	}
}
